import 'package:cloud_medicine/components/util.dart';
import 'package:flutter/material.dart';
import 'package:package_info/package_info.dart';

class AboutPage extends StatefulWidget {
  AboutPage({Key key}) : super(key: key);

  @override
  _AboutPageState createState() => _AboutPageState();
}

class _AboutPageState extends State<AboutPage> {
  bool _loading = false;
  PackageInfo packageInfo;
  String version;

  Future<Null> _init() async {
    setState(() {
      _loading = true;
    });
    packageInfo = await PackageInfo.fromPlatform();
    version = packageInfo.version;
    if (mounted) {
      setState(() {
        _loading = false;
      });
    }
    return;
  }

  @override
  void initState() {
    super.initState();
    _init();
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
        appBar: AppBar(
          title: Text('关于我们'),
          centerTitle: true,
        ),
        body: _loading
            ? loadingWidget(_loading)
            : Container(
                padding: EdgeInsets.only(top: 15, left: 25, right: 25),
                child: Column(
                  crossAxisAlignment: CrossAxisAlignment.center,
                  children: [
                    Container(
                        child: Image.asset(
                      'images/logo.png',
                      width: 150,
                      height: 150,
                    )),
                    Container(
                      child: Text(
                        '云家医',
                        style: TextStyle(fontFamily: 'title', fontSize: 35),
                      ),
                    ),
                    Column(
                      children: [
                        Container(
                          padding: EdgeInsets.only(top: 10, bottom: 40),
                          child: Text('版本号：' + version),
                        ),
                        Container(
                          padding: EdgeInsets.only(bottom: 30),
                          child: Text(
                            '我们致力于建立一个精准的线上预诊与药物配送的平台,来填补目前校园内线上就医平台的稀缺。',
                            style: TextStyle(color: Colors.grey),
                          ),
                        ),
                        Row(
                          mainAxisAlignment: MainAxisAlignment.spaceBetween,
                          children: [
                            Text('客服邮箱'),
                            SelectableText('1974210463@qq.com')
                          ],
                        ),
                        Divider(),
                      ],
                    )
                  ],
                ),
              ),
        floatingActionButton: Align(
          alignment: Alignment.bottomCenter,
          child: Text(
            'Copyright 2020',
            style: TextStyle(color: Colors.grey[400], fontSize: 13),
          ),
        ));
  }
}
